package cn.arnold.queue;

import java.util.Scanner;

public class TestQueue {
    public static void main(String[] args) {
        CircleArrayQueue circleArrayQueue = new CircleArrayQueue(4);
        char key = ' ';   // 接受用户输入
        Scanner scanner = new Scanner(System.in);
        boolean loop = true;
        while (loop) {
            System.out.println("s(show)：查看队列数据");
            System.out.println("g(get)：取出队列数据");
            System.out.println("a(add)：添加队列数据");
            System.out.println("h(head)：查看头数据");
            System.out.println("e(exit)：退出");
            key = scanner.next().charAt(0);
            switch (key) {
                case 's':
                    circleArrayQueue.showQueue();
                    break;
                case 'a':
                    System.out.println("请输入一个数");
                    circleArrayQueue.addQueue(scanner.nextInt());
                    break;
                case 'g':
                    System.out.println("取出的数据是：" + circleArrayQueue.getQueue());
                    break;
                case 'h':
                    System.out.println("头数据是：" + circleArrayQueue.showHead());
                    break;
                case 'e':
                    scanner.close();
                    loop = false;
                    break;
                default:
                    break;
            }
        }
        System.out.println("程序退出...");
    }
}
